package com.sorting;

/**
 * Created by nkrivko on 23.12.2014.
 */
public class InsertionSort implements Sort {
    @Override
    public void sort(char[] s) {
        int length = s.length;
        for (int i = 1; i < length; i++) {
            for (int j = i; j > 0 && (s[j] < s[j - 1]); j--) {
                Util.exchange(s, j, j - 1);
            }
        }
        System.out.print("InsertionSort: ");
        Util.show(s);
    }
}
